<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>添加会议</title>
    <link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/mui.picker.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/t_style.css"/>
    <script src="../../js/vue.js"></script>
    <script src="../../js/mui.min.js"></script>
    <script src="../../js/mui.picker.min.js"></script>
    <script src="../../js/jquery.min.js"></script>
    <script src="../../js/main.js"></script>
    <script src="../../js/jquery.flexText.min.js"></script>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>
<body>
<div id="app" v-cloak>
    <header class="mui-bar mui-bar-nav">
        <span class="back" @click="back"></span>
        <span class="cross" @click="close"></span>
        <h1 class="mui-title" style="left: 80px;right: 80px">添加会议</h1>
    </header>
    <div class="mui-content" style="padding-bottom: 70px">
    <div class="title">
        <p style="margin-bottom: 0">最后保存：{{ saveTime|getData}}</p>
        <div class="clearFix"></div>
    </div>
        <div class="me-box" style="margin-top: 0">
            <div class="me-title">
                <div class="me-title-t fl">会议主题：</div>
                <div class="me-title-i">
                    <input type="text" v-model="title" placeholder="请输入会议主题"/>
                </div>
            </div>
            <div class="me-content">
                <div class="me-title-t fl">会议内容：</div>
                <div class="me-title-i">
                    <textarea v-model="content" placeholder="请输入会议内容"></textarea>
                </div>
            </div>
            <div class="me-title">
                <div class="me-title-t fl">会议地点：</div>
                <div class="me-title-i">
                    <input type="text" v-model="place" placeholder="请输入会议地点"/>
                </div>
            </div>
            <div class="me-title">
                <div class="me-title-t fl">开始时间：</div>
                <div class="me-title-i">
                    <input type="text" placeholder="请选择会议时间" id="result" data-options='{}' style="text-align: right;color: #2c9ae8;"/>
                </div>
            </div>
        </div>
        <div class="add-sender add-me">
            <p>参会人<span>（点击头像可删除）</span></p>
            <div class="report-headimg fl" style="margin-top: 6px;margin-right: 5px" v-for="(item,index) in selected" @click="del(index)">{{item.name|getHName}}</div>
            <div style="float:left;">
                <div class="add-btn fl" @click="open_popup(1)"></div>
                <p class="sender">添加</p>
            </div>
            <div class="clearFix"></div>
        </div>
        <div class="add-sender add-me">
            <p>会议记录员<span>（唯一）</span></p>

            <div class="report-headimg fl" style="margin-top: 6px;margin-right: 5px" v-for="(item,index) in onlyOneArr" @click="del_c(index)">{{item.name|getHName}}</div>
            <div style="float:left;">
                <div class="add-btn fl" @click="open_popup(2)"></div>
                <p class="sender">添加</p>
            </div>
            <div class="clearFix"></div>
        </div>
        <div class="report-footer">
            <div class="submit-btn" @click="submit">提交</div>
        </div>
    </div>
    <div class="popup-bg" v-show="dept">
        <header class="mui-bar mui-bar-nav">
            <span class="back" @click="go_back"></span>
            <h1 class="mui-title">选择接收人</h1>
        </header>
        <div class="popup-content">
            <div class="mui-input-row mui-search">
                <span class="mui-icon mui-icon-search" @click="search"></span>
                <input type="text" :class="{shortter:isSearch}" v-model="searchInfo" placeholder="搜索用户名">
                <span class="cancel"  @click="go_back" v-if="isSearch">取消</span>
                <div class="crumbs" v-if="!isSearch">
                    <ul>
                        <li style="color: #2c9ae8" @click="show_info(true, 0)" v-text="companyName">天津中新智冠信息技术有限公司</li>
                        <li v-for="(item, index) in crumbs" @click="show_info(false, index)">&nbsp;>&nbsp;{{item.name}}</li>
                        <div class="clear"></div>
                    </ul>
                </div>
            </div>
            <ul class="popup-list" :class="isSearch?'popup-list-sec':'popup-list-fir'">
                <li v-for="(item, index) in depts">
                     <div class="fr popup-next" v-show="item.show" @click="show_next(index,1)" >
                        <span>{{item.total}}</span>
                        <img src="../../images/xuanzebumen_right.png" alt="">
                    </div>
                    <div class="popup-info">
                        <input type="checkbox" :checked="item.check" @click="toggle(index)">
                        <div class="report-top" style="padding: 6px 0;float: left;margin-left: 10px">
                            <div class="report-headimg fl" style="margin-top: 2px" v-if="item.show" v-text="item.hName"></div>
                            <div class="report-headimg fl" style="margin-top: 2px" v-else="item.show">{{item.name | getHName}}</div>
                            <div class="report-info">
                                <p style="line-height: 45px">{{item.name}}</p>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                </li>
            </ul>
        </div>

        <div class="popup-footer">
            <div class="haveSelected">已选择: <span v-text="num==1?selected_num:checked_num"></span>人</div>
            <div class="popup-footer-btn fr" @click="confirm">
                确定
            </div>
            <div class="clear"></div>
        </div>
    </div>
    <div class="popup-bg" v-show="selectOnly">
        <header class="mui-bar mui-bar-nav">
            <span class="back" @click="go_back"></span>
            <h1 class="mui-title">选择接收人</h1>
        </header>
        <div class="popup-content">
            <div class="mui-input-row mui-search">
                <span class="mui-icon mui-icon-search" @click="search"></span>
                <input type="text" :class="{shortter:isSearch}" v-model="searchInfo" placeholder="搜索用户名">
                <span class="cancel"  @click="go_back" v-if="isSearch">取消</span>
                <div class="crumbs" v-if="!isSearch">
                    <ul>
                        <li style="color: #2c9ae8" @click="show_info(true, 0)" v-text="companyName"></li>
                        <li v-for="(item, index) in crumbs" @click="show_info(false, index)">&nbsp;>&nbsp;{{item.name}}</li>
                        <div class="clear"></div>
                    </ul>
                </div>
            </div>
            <ul class="popup-list" :class="isSearch?'popup-list-sec':'popup-list-fir'">
                <li v-for="(item, index) in depts">
                    <div class="fr popup-next" v-show="item.show" @click="show_next(index,2)" >
                        <span>{{item.total}}</span>
                        <img src="../../images/xuanzebumen_right.png" alt="">
                    </div>
                    <div class="popup-info">
                        <input type="checkbox" :checked="item.check" @click="toggle_only(index)" v-show="!item.show">
                        <div class="report-top" style="padding: 6px 0;float: left;margin-left: 10px">
                            <div class="report-headimg fl" style="margin-top: 2px" v-if="item.show" v-text="item.hName"></div>
                            <div class="report-headimg fl" style="margin-top: 2px" v-else="item.show">{{item.name | getHName}}</div>
                            <div class="report-info">
                                <p style="line-height: 45px">{{item.name}}</p>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                </li>
            </ul>
        </div>

        <div class="popup-footer">
            <div class="haveSelected">已选择: <span v-text="onlyOneArr.length"></span>人</div>
            <div class="popup-footer-btn fr" @click="confirm">
                确定
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
</body>
<script>

    var time = "";

    function sendInfoToJava(name) {
        //调用android程序中的方法，并传递参数
        javascript:WebView.showInfoFromJs(name);
    }
    var app = new Vue({
        el: "#app",
        data: function () {
            return {
                saveTime:"",
                popup: false,
                title: "",
                content: "",
                place: "",
                participantsListJson: "",
                recordListJson: "",
                select_num: 0,
                users: [],
                user: false,
                onlyOneArr:[],
                selectOnly:false,
                temp:[],
                userType:"",
                checked_num: 0,
                checked: [],
                dept: false,
                depts: [],
                selected_num: 0,
                selected: [],
                rid: [],
                select_person: [],
                num: 1,
                //                    **********搜索
                searchInfo:"",
                isSearch:false,
                crumbs: [],
                companyName: ""
            }
        },
        filters: {
         getData:function (input) {
               var d = new Date(input);
               var hour = d.getHours();
               var minutes = d.getMinutes();
               return  hour + ':' + minutes;
           },
            getHName: function(input) {
                if(input != null){
                    return input.slice(-2);
                }else{
                    return '';
                }
            }
        },
        methods: {
            back: function () {
                var name = "back";
                sendInfoToJava(name);
            },
            close: function () {
                var name = "close";
                sendInfoToJava(name);
            },
            save_time: function () {
                var this_obj = this;
                var date = new Date();
                this_obj.saveTime = date;
                return date;
            },
            submit: function () {
                var this_obj = this;
                if (this_obj.title == "") {
                    mui.toast('请输入会议主题');
                } else if (this_obj.content == "") {
                    mui.toast('请输入会议内容');
                } else if (this_obj.place == "") {
                    mui.toast("请输入会议地点");
                } else if (time == "") {
                    mui.toast("请输入会议开始时间");
                } else if (this_obj.selected.length == 0) {
                    mui.toast("请添加参会人员");
                } else if (this_obj.onlyOneArr.length == 0) {
                    mui.toast("请添加记录员");
                } else {
                    var url = "/meeting/zgMeeting/add";
                    var record = new Object();
                    record.loginName = this_obj.onlyOneArr[0].loginName;
                    record.userName = this_obj.onlyOneArr[0].allName;
                    var participants = new Array();
                    $.each(this_obj.selected, function (index, obj) {
                        var participant = new Object();
                        participant.loginName = obj.loginName;
                        participant.userName = obj.allName;
                        participants.push(participant);
                    });
//                    localStorage.setItem('userName','wangyutao');
                    var data = {
                        "companyId": localStorage.companyId,
                        "createUser":localStorage.userName,
                        "participantsListJson": JSON.stringify(participants),
                        "recordListJson": JSON.stringify(record),
                        "startTime": time + ":00",
                        "zgMeetingTextExtendList": [
                            {"content": this_obj.title, "title": "会议主题"},
                            {"content": this_obj.content, "title": "会议内容"},
                            {"content": this_obj.place, "title": "会议地点"},
                        ]
                    };
                    common_ajax(url, data, function (res) {
                        mui.toast("发送成功");
                        setTimeout(function () {
                            var name = "go";
                            //sendInfoToJava(name);
                            //todo 页面跳转
                            window.location.href = "meeting_arrange.html"
                        }, 1500);
                    }, function (res) {
                        mui.toast("发送失败");
                    });
                }
            },
            open_popup: function (msg) {
                var this_obj = this;
                this_obj.dept = true;
                var number = 0;
                this_obj.rid.push(number);
                if(msg == 2){
                    this_obj.selectOnly = true;
                }else{
                    this_obj.selectOnly = false;
                }
                show_depts(number,msg);
            },
            search: function() {
                var this_obj = this;
                this_obj.isSearch = true;
                var url = "/user/selectUserByCompanyId";
                var postData = {
                    "companyId": localStorage.companyId,//必須傳
                    "name": this_obj.searchInfo
                };
                common_ajax(url,postData,function (res) {
                    if(res.code < 0){
                        mui.toast(res.errorMsg);
                    }else {
                        this_obj.depts = res.obj;
                        if (this_obj.selectOnly) {
                            for (var i in this_obj.onlyOneArr) {
                                for (var j in this_obj.depts) {
                                    if (this_obj.onlyOneArr[i]['loginName'] == this_obj.depts[j]['loginName']) {
                                        this_obj.depts[j]['check'] = true;
                                    } else {
                                        this_obj.depts[j]['check'] = false;
                                    }
                                }
                            }
                        } else {
                            for (var i in this_obj.selected) {
                                for (var j in this_obj.depts) {
                                    if (this_obj.selected[i]['loginName'] == this_obj.depts[j]['loginName']) {
                                        this_obj.depts[j]['check'] = true;
                                    } else if (!this_obj.depts[j]['check']) {
                                        this_obj.depts[j]['check'] = false;
                                    }
                                }
                            }
                        }
                    }
                },function (res) {
                    mui.toast("请求失败");
                });
            },
            show_next: function (index,msg) {
                var this_obj = this;
                if(this_obj.depts[index]['sel_able'] == true){
                    var number = this_obj.depts[index]['id'];
                    var name = this_obj.depts[index]['name'];
                    this_obj.crumbs.push({id: number,name: name});
                    this_obj.rid.push(number);
                    show_depts(number,msg);
                }
            },
            toggle: function (index) {
                var this_obj = this;
                var url = "/organization/dept";
                if(this_obj.depts[index]['check'] == null || this_obj.depts[index]['check'] == false){
                    this_obj.depts[index]['check'] = true;
                    this_obj.depts[index]['sel_able'] = false;
                    if(this_obj.depts[index]['show'] == true){
                        recursion(this_obj.depts[index]['id']);
                    }else{
                        if(this_obj.creatUserName == this_obj.depts[index]['loginName']){
                            mui.toast("自己不能为会议记录员");
                            this_obj.depts[index]['check'] = false;
                        }else{
                            if(this_obj.onlyOneArr.length > 0){
                                for(var i in this_obj.onlyOneArr){
                                    if(this_obj.onlyOneArr[i]['loginName'] != this_obj.depts[index]['loginName']){
                                        this_obj.selected.push({id: this_obj.depts[index]['id'],hName: this_obj.depts[index]['hName'],name: this_obj.depts[index]['name'],loginName: this_obj.depts[index]['loginName']});

                                    }else{
                                        this_obj.depts[index]['check'] = false;
                                        mui.toast(this_obj.depts[index]['name'] +"已经为参会人!");
                                    }
                                }
                            }else{
                                this_obj.selected.push({id: this_obj.depts[index]['id'],hName: this_obj.depts[index]['hName'],name: this_obj.depts[index]['name'],loginName: this_obj.depts[index]['loginName']});

                            }
                        }
                        this_obj.selected_num = this_obj.selected.length;
                    }
                }else{
                    this_obj.depts[index]['check'] = false;
                    this_obj.depts[index]['sel_able'] = true;
                    if(this_obj.depts[index]['show'] == true){
                        del(this_obj.depts[index]['id']);
                        function del(deptId) {
                            var data = {
                                "companyId": localStorage.companyId, //公司ID
                                "deptId": deptId
                            };
                            common_ajax(url,data,function (res) {
                                if(res.code < 0){
                                    mui.toast(res.errorMsg);
                                }else{
                                    console.log(res);
                                    if(res.obj.depts.length == 0){
                                        for(var j in res.obj.users){
                                            for(var y = 0;y < this_obj.selected.length;y++){
                                                if(this_obj.selected[y]['id'] == res.obj.users[j]['id']){
                                                    this_obj.selected.splice(y,1);
                                                    y--;
                                                }
                                            }
                                        }
                                    }else{
                                        for(var i in res.obj.depts){
                                            del(res.obj.depts[i]['id']);
                                        }
                                        for(var x in res.obj.users){
                                            for(var a = 0;a < this_obj.selected.length;a++){
                                                if(this_obj.selected[a]['id'] == res.obj.users[x]['id']){
                                                    this_obj.selected.splice(a,1);
                                                    a--;
                                                }
                                            }
                                        }
                                    }
                                    console.log(this_obj.selected);
                                    this_obj.selected_num = this_obj.selected.length;
                                }
                            },function (res) {
                                mui.toast("拉取联系人失败");
                            });
                        }
                    }else{
                        for(var a = 0;a < this_obj.selected.length;a++){
                            if(this_obj.selected[a]['id'] == this_obj.depts[index]['id']){
                                this_obj.selected.splice(a,1);
                                a--;
                            }
                        }
                        this_obj.selected_num = this_obj.selected.length;
                    }
                }
            },
            toggle_only: function(index) {
                var this_obj = this;
                var url = "/organization/dept";
                if(this_obj.depts[index]['check']){
                    this_obj.depts[index]['check'] = false;
                    this_obj.onlyOneArr.splice(0,1)
                }else{
                    for(var i in this_obj.depts){
                        this_obj.depts[i]['check'] = false;
                    }
                    this_obj.depts[index]['check'] = true;
                    this_obj.onlyOneArr.splice(0,1,{id: this_obj.depts[index]['id'],hName: this_obj.depts[index]['hName'],name: this_obj.depts[index]['name'],loginName: this_obj.depts[index]['loginName']});
                }
            },
            confirm: function () {
                var this_obj = this;
                this_obj.searchInfo ="";
                this_obj.dept = false;
                this_obj.isSearch = false;
                if(this_obj.selectOnly){
                    this_obj.selectOnly = false;
                    if(this_obj.selected.length > 0 ){
                        for(var i in this_obj.selected){
                            if(this_obj.onlyOneArr.length > 0 && this_obj.selected[i]['id'] == this_obj.onlyOneArr[0]['id']){
                                mui.toast(this_obj.onlyOneArr[0]['name']+"已经为会议记录员");
                                this_obj.onlyOneArr = [];
                            }
                        }
                    }
                    if(this_obj.onlyOneArr.length > 0 && this_obj.onlyOneArr[0]['loginName'] == this_obj.creatUserName){
                        mui.toast("自己不能为参会人!");
                        this_obj.onlyOneArr = [];
                    }
                }else{
                    var arr = unique(this_obj.selected);
                    this_obj.selected = arr.concat();
                }

            },
            del: function (index) {
                var this_obj = this;
                this_obj.selected.splice(index, 1);
            },
            del_c:function(index) {
              var this_obj = this;
              this_obj.onlyOneArr.splice(index, 1);
            },
            go_back: function () {
                var this_obj = this;
                console.log(this_obj.rid);
                if(this_obj.isSearch){
                    this_obj.isSearch = false;
                    this_obj.searchInfo = "";
                    if(this_obj.selectOnly){
                        show_depts(this_obj.rid[this_obj.rid.length-1],2);
                    }else{
                        show_depts(this_obj.rid[this_obj.rid.length-1],1);
                    }
                }else {
                    if (this_obj.rid[this_obj.rid.length - 1] == 0) {
                        var btnArray = ['取消', '确定'];
                        mui.confirm('确定要取消本次操作吗？', '', btnArray, function (e) {
                            if (e.index == 1) {
                                this_obj.dept = false;
                                this_obj.selectOnly = false;
                                this_obj.rid = [];
                                this_obj.selected = [];
                                this_obj.selected_num = this_obj.selected.length;
                            }
                        })
                    } else {
                        this_obj.crumbs.pop();
                        this_obj.rid.pop();
                        console.log(this_obj.rid);
                        var number = this_obj.rid[this_obj.rid.length - 1];
                        if(this_obj.selectOnly){
                            show_depts(number,2);
                        }else{
                            show_depts(number,1);
                        }
                    }
                }
            },
            show_info: function (flag, index) {
                var this_obj = this;
                if(flag == true){
                    if(this_obj.selectOnly){
                        show_depts(index,2);
                    }else{
                        show_depts(index,1);
                    }
                    this_obj.crumbs = [];
                }else{
                    var number = this_obj.crumbs[index]['id'];
                   if(this_obj.selectOnly){
                      show_depts(number,2);
                  }else{
                      show_depts(number,1);
                  }
                    var len = this_obj.crumbs.length - (index + 1);
                    this_obj.crumbs.splice(index + 1, len);
                }
            }
        }
    });
    app.save_time();
    setInterval(app.save_time(),20*1000);
    (function($) {
        $.init();
        var btn = document.getElementById("result");
        btn.addEventListener('tap',function () {
            var _self = this;
            if(_self.picker) {
                _self.picker.show(function (rs) {
                    _self.value = rs.text;
                    _self.picker.dispose();
                    _self.picker = null;
                });
            } else {
                var optionsJson = this.getAttribute('data-options') || '{}';
                var options = JSON.parse(optionsJson);
                var id = this.getAttribute('id');
                _self.picker = new $.DtPicker(options);
                _self.picker.show(function(rs) {
                    _self.value = rs.text;
                    time = rs.text;
                    _self.picker.dispose();
                    _self.picker = null;
                });
            }
        },false);
    })(mui);
    //去重
    function unique(arr) {
        var result = [], isRepeated;
        for (var i = 0; i < arr.length; i++) {
            isRepeated = false;
            for (var j = 0; j < result.length; j++) {
                if (arr[i]['loginName'] == result[j]['loginName']) {
                    isRepeated = true;
                    mui.toast("您已经选择了"+arr[i].name);
                    break;
                }
            }
            if (!isRepeated) {
                result.push(arr[i]);
            }
        }
        return result;
    }
    //已经选好的的添加到当前数组中
    function arrayIntersection(a, b){
        for(var i=0;i<b.length;i++){
            for(var j=0;j<a.length;j++){
                if(b[i].id==a[j].id){
                    b[i].check=true;
                    break;
                }
            }
        }
    }
    //下一级全选则本级显示选中
    function check_group(department,select){
        var all_select=0;
        for(var i=0;i<department.length;i++){
            var now_select=0;
            for(var j=0;j<select.length;j++){
                if(department[i].id==select[j].id){
                    now_select=1;
                    break;
                }
            }
            if(now_select!=1)break;
            if(i==department.length-1){
                all_select=1;
            }
        }
        return all_select;
    }
    function show_depts(deptId,msg) {
        var url = "/organization/dept";
        var data = {
            "companyId": localStorage.companyId, //公司ID
            "deptId": deptId // 初始传入0
        };
        common_ajax(url,data,function (res) {
            if(res.code < 0){
                mui.toast(res.errorMsg);
            }else{
                console.log(res);
                app.depts = [];
                for(var i in res.obj.depts){
                    var hName = res.obj.depts[i]['name'].substr(0,2);
                    app.depts.push({id: res.obj.depts[i]['id'],total: res.obj.depts[i]['total'],hName: hName,name: res.obj.depts[i]['name'],check:false,show: true,sel_able: true});
                    check_recursion(app.depts[i]['id'],i);
                }
                for(var j in res.obj.users){
                    var eName = res.obj.users[j]['name'].slice(-2);
                    app.depts.push({id: res.obj.users[j]['id'],total: res.obj.users[j]['total'],hName: eName,name: res.obj.users[j]['name'],check:false,show: false,sel_able: true,loginName: res.obj.users[j]['loginName']});
                }
                if(msg == 1){
                    arrayIntersection(app.selected, app.depts);
                }else if(msg == 2){
                    arrayIntersection(app.onlyOneArr, app.depts);
                }
            }
        },function (res) {
            mui.toast("拉取联系人失败");
        })
    }
    function check_recursion(deptId, index) {
        var url = "/organization/dept";
        var data = {
            "companyId": localStorage.companyId, //公司ID
            "deptId": deptId
        };
        common_ajax(url,data,function (res) {
            if(res.code < 0){
                mui.toast(res.errorMsg);
            }else{
                app.select_person = [];
                if(res.obj.depts.length == 0){
                    for(var j in res.obj.users){
                        var eName = res.obj.users[j]['name'].slice(-2);
                        app.select_person.push({id: res.obj.users[j]['id'],hName: eName,name: res.obj.users[j]['name'],loginName: res.obj.users[j]['loginName']});
                    }
                }else{
                    for(var i in res.obj.depts){
                        check_recursion(res.obj.depts[i]['id']);
                    }
                    for(var x in res.obj.users){
                        var myName = res.obj.users[x]['name'].slice(-2);
                        app.select_person.push({id: res.obj.users[x]['id'],hName: myName,name: res.obj.users[x]['name'],loginName: res.obj.users[x]['loginName']});
                    }
                }
                if(check_group(app.select_person, app.selected) == 1){
                    app.depts[index]['check'] = true;
                }
            }
        },function (res) {
            mui.toast("拉取联系人失败");
        });
    }
    function recursion(deptId) {
        var url = "/organization/dept";
        var data = {
            "companyId": localStorage.companyId, //公司ID
            "deptId": deptId
        };
        common_ajax(url,data,function (res) {
            if(res.code < 0){
                mui.toast(res.errorMsg);
            }else{
                console.log(res);
                if(res.obj.depts.length == 0){
                    for(var j in res.obj.users){
                        var eName = res.obj.users[j]['name'].slice(-2);
                        if(app.creatUserName == res.obj.users[j]['loginName']){
                            mui.toast("自己不能为会议记录员");
                            for(var i in app.depts){
                                if(app.depts[i]['id'] == deptId){
                                    app.depts[i]['check'] = false
                                }
                            }
                        }else{
                            if(app.onlyOneArr.length > 0){
                                for(var i in app.onlyOneArr){
                                    if(app.onlyOneArr[i]['loginName'] != res.obj.users[j]['loginName']){
                                        app.selected.push({id: res.obj.users[j]['id'],hName: eName,name: res.obj.users[j]['name'],loginName: res.obj.users[j]['loginName']});
                                    }else{
                                        mui.toast(res.obj.users[j]['name'] +"已经为参会人!");
                                        for(var i in app.depts){
                                            if(app.depts[i]['id'] == deptId){
                                                app.depts[i]['check'] = false
                                            }
                                        }
                                    }
                                }
                            }else{
                                app.selected.push({id: res.obj.users[j]['id'],hName: eName,name: res.obj.users[j]['name'],loginName: res.obj.users[j]['loginName']});
                            }

                        }
                        //                            app.selected.push({id: res.obj.users[j]['id'],hName: eName,name: res.obj.users[j]['name'],loginName: res.obj.users[j]['loginName']});
                    }
                }else{
                    for(var i in res.obj.depts){
                        recursion(res.obj.depts[i]['id']);
                    }
                    for(var x in res.obj.users){
                        var myName = res.obj.users[x]['name'].slice(-2);
                        //                            app.selected.push({id: res.obj.users[x]['id'],hName: myName,name: res.obj.users[x]['name'],loginName: res.obj.users[x]['loginName']});
                        if(app.creatUserName == res.obj.users[x]['loginName']){
                            mui.toast("自己不能为会议记录员")
                            for(var i in app.depts){
                                if(app.depts[i]['id'] == deptId){
                                    app.depts[i]['check'] = false
                                }
                            }
                        }else{
                            if(app.onlyOneArr.length > 0){
                                for(var i in app.onlyOneArr){
                                    if(app.onlyOneArr[i]['loginName'] != res.obj.users[j]['loginName']){
                                        app.selected.push({id: res.obj.users[x]['id'],hName: myName,name: res.obj.users[x]['name'],loginName: res.obj.users[x]['loginName']});
                                    }else{
                                        mui.toast(res.obj.users[x]['name'] +"已经为参会人!");
                                        for(var i in app.depts){
                                            if(app.depts[i]['id'] == deptId){
                                                app.depts[i]['check'] = false
                                            }
                                        }
                                    }
                                }
                            }else{
                                app.selected.push({id: res.obj.users[x]['id'],hName: myName,name: res.obj.users[x]['name'],loginName: res.obj.users[x]['loginName']});
                            }
                        }
                    }
                }
                console.log(app.selected);
                app.selected_num = app.selected.length;
            }
        },function (res) {
            mui.toast("拉取联系人失败");
        });
    }
    function sendInfoToJava(name) {
        //调用android程序中的方法，并传递参数
        javascript:WebView.showInfoFromJs(name);
    }

    var name = "companyId" + localStorage.companyId;
    sendInfoToJava(name);

    //在android代码中调用此方法
    function showInfoFromJava(msg){
        app.companyName = msg;
    }
    $(function () {
        $('textarea').flexText();
    });
</script>
</html>